var Home = {
  // 获取数据
  getList() {
    var url = "http://localhost:3000/houseList";
    axios
      .get(url)
      .then(function (res) {
        console.log(res.data);
        Home.render(res.data);
      })
      .catch(function (err) {
        console.error("网络请求失败", err);
      });
  },

  render(list) {
    var htmlStr = "";
    list.forEach(function (item) {
      htmlStr += `
                <a class="item" href="./house-dail.html?id=${item.id}"> 
                    <div class="img-box rel"><img class="w100pc"
                            src="${item.imageUrl}"
                            alt=""><span class="h40 fcc price fff abs">¥3288</span></div>
                    <div class="desc f14 pb-10">
                        <h3 class="mt-10 f12">大鹏古城·​千语居7房客栈</h3>
                        <p class="mt-10 f10 lh15">浪漫美景+免费WIFI、电视、齐全设备=完美假期。</p>
                        <p class="city fcc mt-5 f10">深圳●大鹏新区</p>
                    </div>
                </a> 
                `;
    });
    $("#house-list").html(htmlStr);
  },
};
// Home.getList();

var $http = axios.create({
  baseURL: "http://localhost:3000",
});

new Vue({
  el: "#app",
  data: {
    houseList: [],
    sceneList: [],
  },
  created() {
    $http.get("/house").then((res) => {
      this.houseList = res.data;
    });
    $http.get("/scene").then((res) => {
      this.sceneList = res.data;
    });
  },
});
